var history = require('connect-history-api-fallback')
const express = require('express')
const app = express()

app.set('secret', 'jirtayo')

require('./plugins/db')(app)
require('./routes/admin/index')(app)
require('./routes/web/index')(app)

// 访问图片静态路径
app.use('/shopadmin',history(), express.static(`${__dirname}/shopadmin`))
app.use('/shopweb',history(), express.static(`${__dirname}/shopweb`))
app.use('/uploads',history(), express.static(__dirname + '/uploads'))

app.use(require('cors')()) // 跨域
app.use(express.json()) // 使用json
app.listen(3001, () => {
  console.log('http://localhost:3001')
})